<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, user-scalable=no">
  <meta name="description" content="API docs for the call method from the SwaggerUI class, for the Dart programming language.">
  <title>call method - SwaggerUI class - shelf_swagger_ui library - Dart API</title>


  
  <link rel="preconnect" href="https://fonts.gstatic.com">
  <link href="https://fonts.googleapis.com/css2?family=Roboto+Mono:ital,wght@0,300;0,400;0,500;0,700;1,400&display=swap" rel="stylesheet">
  <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
  
  <link rel="stylesheet" href="../../static-assets/github.css?v1">
  <link rel="stylesheet" href="../../static-assets/styles.css?v1">
  <link rel="icon" href="../../static-assets/favicon.png?v1">

  
</head>


<body data-base-href="../../"
      data-using-base-href="false">

<div id="overlay-under-drawer"></div>

<header id="title">
  <button id="sidenav-left-toggle" type="button">&nbsp;</button>
  <ol class="breadcrumbs gt-separated dark hidden-xs">
    <li><a href="../../index.html">shelf_swagger_ui</a></li>
    <li><a href="../../shelf_swagger_ui/shelf_swagger_ui-library.html">shelf_swagger_ui</a></li>
    <li><a href="../../shelf_swagger_ui/SwaggerUI-class.html">SwaggerUI</a></li>
    <li class="self-crumb">call method</li>
  </ol>
  <div class="self-name">call</div>
  <form class="search navbar-right" role="search">
    <input type="text" id="search-box" autocomplete="off" disabled class="form-control typeahead" placeholder="Loading search...">
  </form>
</header>

<main>


  <div id="dartdoc-main-content" class="main-content">
      <div>
<h1><span class="kind-method">call</span> method 
    <a href="https://dart.dev/null-safety" class="feature feature-null-safety" title="Supports the null safety language feature.">Null safety</a>
</h1></div>

    <section class="multi-line-signature">
      

<span class="returntype"><a href="https://api.flutter.dev/flutter/dart-async/FutureOr-class.html">FutureOr</a><span class="signature">&lt;<wbr><span class="type-parameter"><a href="https://pub.dev/documentation/shelf/1.3.1/shelf/Response-class.html">Response</a></span>&gt;</span></span>
<span class="name ">call</span>(<wbr><ol class="parameter-list"><li><span class="parameter" id="call-param-request"><span class="type-annotation"><a href="https://pub.dev/documentation/shelf/1.3.1/shelf/Request-class.html">Request</a></span> <span class="parameter-name">request</span></span></li>
</ol>)

      

    </section>
    
<section class="desc markdown">
  <p>Shelf Handler</p>
<pre class="language-dart"><code class="language-dart">final swaggerHandler = SwaggerUI(
 'swagger/swagger.yaml',
 title: 'Ship API',
 deepLink: true,
);

var server = await io.serve(swaggerHandler, '0.0.0.0', 4000);
</code></pre>
</section>


    
<section class="summary source-code" id="source">
  <h2><span>Implementation</span></h2>
  <pre class="language-dart"><code class="language-dart">FutureOr&lt;Response&gt; call(Request request) {
  final file = File(fileSchemaPath);
  final mainSpec = basename(file.path);
  final dirParent = file.parent;
  final uri = request.url;
  final path = uri.path;

  if (path.contains(&#39;yaml&#39;) || path.contains(&#39;json&#39;)) {
    var filePath = _resolveFilePath(dirParent, path);
    final file = File(filePath);
    return Response.ok(file.readAsBytesSync());
  }
  return Response.ok(headers: {
    HttpHeaders.contentTypeHeader: ContentType(&#39;text&#39;, &#39;html&#39;, charset: &#39;utf-8&#39;).toString(),
  }, &#39;&#39;&#39;
&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot;&gt;
&lt;head&gt;
&lt;meta charset=&quot;utf-8&quot; &#47;&gt;
&lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot; &#47;&gt;
&lt;meta
  name=&quot;description&quot;
  content=&quot;SwaggerUI&quot;
&#47;&gt;
&lt;title&gt;$title&lt;&#47;title&gt;
&lt;link rel=&quot;stylesheet&quot; href=&quot;https:&#47;&#47;unpkg.com&#47;swagger-ui-dist@4.5.0&#47;swagger-ui.css&quot; &#47;&gt;
&lt;&#47;head&gt;
&lt;body&gt;
&lt;div id=&quot;swagger-ui&quot;&gt;&lt;&#47;div&gt;
&lt;script src=&quot;https:&#47;&#47;unpkg.com&#47;swagger-ui-dist@4.5.0&#47;swagger-ui-bundle.js&quot; crossorigin&gt;&lt;&#47;script&gt;

&lt;script&gt;
window.onload = () =&gt; {
  window.ui = SwaggerUIBundle({
    dom_id: &#39;#swagger-ui&#39;,
    docExpansion: &#39;${docExpansion.name}&#39;,
    deepLinking: $deepLink,
    url: &quot;$mainSpec&quot;,
    syntaxHighlight: {
      activate: true,
      theme: &#39;${syntaxHighlightTheme.theme}&#39;,
    },
    persistAuthorization: $persistAuthorization,
  });
};
&lt;&#47;script&gt;
&lt;&#47;body&gt;
&lt;&#47;html&gt;
&#39;&#39;&#39;);
}</code></pre>
</section>


  </div> <!-- /.main-content -->

  <div id="dartdoc-sidebar-left" class="sidebar sidebar-offcanvas-left">
    <header id="header-search-sidebar" class="hidden-l">
  <form class="search-sidebar" role="search">
    <input type="text" id="search-sidebar" autocomplete="off" disabled class="form-control typeahead" placeholder="Loading search...">
  </form>
</header>

<ol class="breadcrumbs gt-separated dark hidden-l" id="sidebar-nav">
  <li><a href="../../index.html">shelf_swagger_ui</a></li>
  <li><a href="../../shelf_swagger_ui/shelf_swagger_ui-library.html">shelf_swagger_ui</a></li>
  <li><a href="../../shelf_swagger_ui/SwaggerUI-class.html">SwaggerUI</a></li>
  <li class="self-crumb">call method</li>
</ol>


    <h5>SwaggerUI class</h5>
    <ol>

        <li class="section-title"><a href="../../shelf_swagger_ui/SwaggerUI-class.html#constructors">Constructors</a></li>
          <li><a href="../../shelf_swagger_ui/SwaggerUI/SwaggerUI.html">SwaggerUI</a></li>


    <li class="section-title">
      <a href="../../shelf_swagger_ui/SwaggerUI-class.html#instance-properties">Properties</a>
    </li>
    <li><a href="../../shelf_swagger_ui/SwaggerUI/deepLink.html">deepLink</a></li>
    <li><a href="../../shelf_swagger_ui/SwaggerUI/docExpansion.html">docExpansion</a></li>
    <li><a href="../../shelf_swagger_ui/SwaggerUI/fileSchemaPath.html">fileSchemaPath</a></li>
    <li class="inherited"><a href="https://api.flutter.dev/flutter/dart-core/Object/hashCode.html">hashCode</a></li>
    <li><a href="../../shelf_swagger_ui/SwaggerUI/persistAuthorization.html">persistAuthorization</a></li>
    <li class="inherited"><a href="https://api.flutter.dev/flutter/dart-core/Object/runtimeType.html">runtimeType</a></li>
    <li><a href="../../shelf_swagger_ui/SwaggerUI/syntaxHighlightTheme.html">syntaxHighlightTheme</a></li>
    <li><a href="../../shelf_swagger_ui/SwaggerUI/title.html">title</a></li>

    <li class="section-title"><a href="../../shelf_swagger_ui/SwaggerUI-class.html#instance-methods">Methods</a></li>
    <li><a href="../../shelf_swagger_ui/SwaggerUI/call.html">call</a></li>
    <li class="inherited"><a href="https://api.flutter.dev/flutter/dart-core/Object/noSuchMethod.html">noSuchMethod</a></li>
    <li class="inherited"><a href="https://api.flutter.dev/flutter/dart-core/Object/toString.html">toString</a></li>

    <li class="section-title inherited"><a href="../../shelf_swagger_ui/SwaggerUI-class.html#operators">Operators</a></li>
    <li class="inherited"><a href="https://api.flutter.dev/flutter/dart-core/Object/operator_equals.html">operator ==</a></li>




</ol>

  </div><!--/.sidebar-offcanvas-->

  <div id="dartdoc-sidebar-right" class="sidebar sidebar-offcanvas-right">
  </div><!--/.sidebar-offcanvas-->

</main>

<footer>
  <span class="no-break">
    shelf_swagger_ui
      0.1.2
  </span>

  
</footer>



<script src="../../static-assets/highlight.pack.js?v1"></script>
<script src="../../static-assets/script.js?v1"></script>



</body>

</html>

